<?php
/**
 * Created by PhpStorm.
 * User: hp
 * Date: 2019/5/13
 * Time: 16:15
 */
 //详情的php
header("Content-Type:application/json;charset=utf-8");
header("Access-Control-Allow-Origin:*");

$_pId="";
if(isset($_REQUEST["pro_id"])){
    $_pId=$_REQUEST["pro_id"];

}
$datalistr=file_get_contents("./goodsjson/goodlist.json");
if($_pId !=""){
    //如果传入id,就通过id返回一条数据
    $arrData = json_decode($datalistr); // 字符串->Array;
    for($i = 0;$i < count($arrData); $i++){
        if($arrData[$i]->pro_id==$_pId){
            print_r(json_encode($arrData[$i]));
            break;
        }
    }
}else{
    print_r($datalistr);
}


